<!DOCTYPE html>
<html>
<head>
<ytata:questionview listname="question" id="$_GET['id']"/>
<include file="public:header" />
<title>{$question.title}</title>
<link rel="stylesheet" href="__PUBLIC__/css/show.css">
</head>

<body>
{:TOP_BACK($question['title'])}
<div class="stit">
<eq name="question.issolve" value="1" >
	<div class="issolve1"></div>
</eq>
<eq name="question.count_praise" value="0">
	<div id="J_praise1_{$question.id}" class="zan font12 J_praise" data-id="{$question.id}" data-type="1">点赞</div>
	<else/>
	<div id="J_praise1_{$question.id}" class="zan font12 J_praise" data-id="{$question.id}" data-type="1">{$question.count_praise}</div>
</eq>

<div class="uinfo">
		<div class="more J_more" data-id="{$question.id}"></div>
		<div class="avatar"><img src="{$question.adduser.avatar}"></div>
	
	<div class="txt">
		  <div class="t font14">{$question.adduser.nickname}<span class="lv font9">LV{$question.adduser.exp_lv}</span></div>
		  <div class="date font10">楼主<span>|</span>{$question.addtime|formatdate}<span>|</span>浏览:{$question.click}</div>
	</div>
</div>
  
  
	  <div class="tcont font18">
		  <neq name="question.reward" value="0" >
		  <span class="gold">{$question.reward}</span>
		  </neq>
		  <!--有标题显示标题，否则显示内容 -->
	  	{$question['title'] ? $question['title'] :$question['describe']}
	  </div>
	  
	  
	  <div class="tag font10">
			<volist name="question.tag" id="vo">
				<div class="tagli">{$vo.tag}</div>
			</volist>
	  </div>
	  
	  
	  <!-- 问题补充列表-->
	 <volist name="question.supp" id="supp">
		  <div class="supp font12">
		  <span class="st" >补充：</span>
		  {$supp.content}
		  </div>
	</volist>
	
	  
	  <notempty name="question.img">
	  <div class="imgs">
	  	<volist name="question.img" id="img">
    	<div class="imgli J_imgs"><img src="{$img.thumb_imgurl}" border="0"></div>
		</volist>
 	 </div>
	 </notempty>
	 
	  
	  <!--有标题的话这里一定要显示内容 -->
	  <notempty name="question.title">
	  <div class="supp font12">
	  {$question.describe}
	  </div>
	  </notempty>  
              
  <!--不是自己发布  并且自己没有回答过 并且（没有解决或者已解决允许回答） -->
   <if condition="($question.uid neq $uid ) AND ($question.is_reply neq '1' ) AND ($question['issolve']=='0' || C('YTATA_ENABLE_ANSWER')=='1')">
  <div class="replybtn J_replybtn" data-id="{$question.id}" reply_nickname="{$question.adduser.nickname}">回答</div>
  </if>
  <!-- 自己发布的显示补充提问-->
    <if condition="($question.uid eq $uid) AND ($question['issolve']=='0')">
	<div class="replybtn J_suppbtn" data-id="{$question.id}">补充</div>
  </if>
</div>



 <!--已经回答过(登录中) -->
<if condition="$question.is_reply eq '1'">
<div class="uu_spacing"></div>
<div class="slist">
	<div class="tits">我的回答<eq name="question.my_reply.optimal" value="1"><span>(最佳答案)</span></eq></div>
		 
                
				
	<div class="lis noborder">
	
		<div class="uinfo">
				  <div class="ulf">
					<div class="avatar"><img src="{$user.avatar}"></div>
					<div class="uname">{$user.nickname}<span class="level">LV{$user.exp_lv}</span></div>
				  </div>
			  	<div class="urt font12">{$question.my_reply.addtime_str}</div>
		</div>
		
		<div class="replytxt ">{$question.my_reply.content}</div>
		
		<volist name="question.my_reply.asked" id="askedli">
				<div class="supp font12">
					<span class="st" >
					<if condition="$askedli.type eq '1'">追答：<else/>追问：</if>
					</span>
					{$askedli.content}
				</div>
		</volist>
		<!--自己追答 -->
		<if condition="$question['issolve']=='0' || C('YTATA_ENABLE_ANSWER')=='1'">
			<div class="askedbtns J_asked" data-rid="{$question.my_reply.id}" reply_nickname="{$question.adduser.nickname}">追答</div>
	 	</if>
				 
		</div>
</div>

</if>
 
<div class="uu_spacing"></div>
<ytata:answer listname="li" qid="$_GET['id']" sort="optimal desc" />
<empty name="li.list">
<div class="empty font12">暂时木有回答呀～～</div>
<else/>
<div class="slist_tit font10">共{$question.answercount}个回答</div>
<div class="slist">
	<eq name="question.issolve" value="1">
		<div class="tits">最佳答案</div>
		<else/>
		<div class="tits">全部答案</div>
	</eq>
	<volist name="li.list" id="answer">
  <div class="lis">
		<div class="uinfo">
		  <div class="ulf">
			<div class="avatar"><img src="{$answer.user.avatar}"></div>
				<div class="uname">{$answer.user.nickname}<span class="level">LV{$answer.user.exp_lv}</span></div>
		  </div>
			  <div class="urt font12">{$answer.user.addtime_str}</div>
		</div>
		<div class="replytxt ">{$answer.content}</div>
		
		<volist name="answer.asked" id="reply">
		<div class="supp font12">
		  <span class="st" ><eq name="reply.type" value="2">追问<else/>追答</eq>：</span>
			{$reply.content}
		</div>
		</volist>
		<!--假如是自己发布的,可以追问和采纳答案 -->
          <if condition="($question.uid eq $uid) AND ($question['issolve']=='0')">
		    <div class="btns font12">
			  <div class="cbtn J_optimal" data-rid="{$answer.id}">采纳答案</div>
			  <div class="cbtn c J_suppask" data-rid="{$answer.id}" reply_nickname="{$answer.user.nickname}">追问</div>
			</div>
		  </if>
		<neq name="answer.praise" value="0">
			<div id="J_praise2_{$answer.id}" class="zan font12 J_praise" data-id="{$answer.id}" data-type="2">{$answer.praise}</div>
			<else/>
			<div id="J_praise2_{$answer.id}" class="zan font12 J_praise" data-id="{$answer.id}" data-type="2">点赞</div>
		</neq>
  </div>
	</volist>
</div>
</empty>

<include file="public:foot" />
<include file="public:photoswipe" />
</body>
<script>
$(document).ready(function () {
	$('.J_more').off().on('click',function(e){
		var qid=$(this).data('id');
		var $Scroll = new UpScroll({
				maskClose: true,
				showCancel: true
		});
		$Scroll.setContent(['关注','收藏','举报']);
		$Scroll.show();

		$Scroll.getList(1).on('click', function() {
        ajax_login('ajax_follow', {objid: qid, type:1});
				$Scroll.fast_hide();
		});

		$Scroll.getList(2).on('click', function() {
				ajax_login('ajax_favorites', {id: qid, type:1});
				$Scroll.fast_hide();
		});

		$Scroll.getList(3).on('click', function() {
				var params = {objid: qid, type: '1'};
				ajax_login('ajax_report', params);
				$Scroll.fast_hide();
		});

	});
	// 提交回答
	$(".J_replybtn").on('click', function () {
		var id = $(this).data('id');
		var reply_nickname = $(this).attr('reply_nickname');
		ajax_login('ajax_reply', {qid: id,reply_nickname:reply_nickname});
	});
	
	// 点赞
	$(".J_praise").click(function (e) {
		var id = $(this).data('id');
		var type = $(this).data('type');
		ajax_login('praise', {id:id,type:type});
  });
	
	// 补充提问
	$(".J_suppbtn").click(function () {
	    var ajax_qsupp_url = '{:U("wechat/question/ajax_question_supp")}';
			var qid = '{$_GET["id"]}';  // 问题ID
      $.getJSON(ajax_qsupp_url, {qid: qid}, function (result) {
          if (result.code == 1) {
              show_form('补充提问',result.data);
              $('.uu_forms').addClass('uu-actionsheet-toggle');
          } else if (result.code == 0) {
              toast(result.msg);
          }
      });
	});
	
	// 追答
	$(".J_asked").click(function () {
      var ajax_asupp_url = '{:U("wechat/question/ajax_question_reply_supp")}';
      var rid = $(this).data('rid');  // 回答ID
	  var reply_nickname = $(this).attr('reply_nickname');
      $.getJSON(ajax_asupp_url, {rid: rid, type:1,reply_nickname:reply_nickname}, function (result) {
          if (result.code == 1) {
              show_form('追答',result.data);
              $('.uu_forms').addClass('uu-actionsheet-toggle');
          } else if (result.code == 0) {
              toast(result.msg);
          }
      });
  });
	
	// 追问
	$(".J_suppask").click(function () {
      var ajax_asupp_url = '{:U("wechat/question/ajax_question_reply_supp")}';
      var rid = $(this).data('rid');  // 回答ID
	  var reply_nickname = $(this).attr('reply_nickname');
      $.getJSON(ajax_asupp_url, {rid: rid, type:2,reply_nickname:reply_nickname}, function (result) {
          if (result.code == 1) {
              show_form('追问',result.data);
              $('.uu_forms').addClass('uu-actionsheet-toggle');
          } else if (result.code == 0) {
              toast(result.msg);
          }
      });
  });
	
	// 采纳答案
	$(".J_optimal").click(function () {
      var ajax_adoption_reply_url = '{:U("wechat/question/ajax_adoption_reply")}';
      var rid = $(this).data('rid');  // 回答ID
      var qid = '{$_GET["id"]}';  // 问题ID
      $(document).dialog({
          type : 'confirm',
          content: '确定采纳为最佳答案吗？',
          onClickConfirmBtn: function(){
              $.getJSON(ajax_adoption_reply_url, {rid:rid,qid:qid}, function(res){
                  if (res.code == 1) {
                      // 成功
                      toast(res.msg, 1);
                      location.reload();
                  } else {
                      toast(res.msg);
                  }
              });
          }
      });
  });
});
</script>
</html>